package com.example.weather.data;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
//用room框架建立数据库
@Database(entities = {City.class},version = 1,exportSchema = false)
public abstract class WeatherDatabase extends RoomDatabase {
    private static WeatherDatabase INSTANCE;
    static public WeatherDatabase getDatabase(Context context){
        if(INSTANCE==null) {
            INSTANCE= Room.databaseBuilder(context,WeatherDatabase.class,"info_database")
                    .allowMainThreadQueries().build();
            //数据库名 info_database
            //表名 City
        }
        return INSTANCE;
    }
    public abstract CityDao getCityDao();
}
